╫HATEVER IS PRINTED ON THE SCREEN CAN BE FADED IN AND OUT FOR A GOOD EFFECT. ╫HILE YOU LEARN HOW TO DO THIS, YOU WILL ALSO BE INTRODUCED TO A BIT OF PROGRAM PLANNING, SOME DIFFERENCES BETWEEN A ╨╥╔╬╘ AND ├╚┴╥ COMMAND, SEVERAL CONTROL CHARACTERS AND TABLE-LESS CONVERSIONS.
╫HEN WE NEED TO DISPLAY A MESSAGE ON THE SCREEN, WE CAN SIMPLY CODE ╨╥╔╬╘"SOME MESSAGE" WITH A SEMICOLON AT THE END, IF IT IS TO RESIDE ON THE BOTTOM LINE OF THE SCREEN. ╫E FOLLOW IT BY CODE THAT WAITS FOR A PERSON TO PRESS SOME KEY. ╬OTHING COULD BE SIMPLER.
┼VERY ONCE IN A WHILE IT'S FUN OR USEFUL TO DRESS UP THE MESSAGE A BIT TO REALLY CATCH SOMEBODY'S EYE. ╚AVE YOU EVER SEEN A COMMERCIAL HOME-COMPUTER VIDEO GAME? ╘HE WRITERS OF GAMES ARE MASTERS AT THIS SORT OF THING. ╫E WON'T DO ANYTHING THAT ELABORATE, BUT WE CAN LOOK AT THE STEPS INVOLVED.
Ç*CN1;--- ╙╔═╨╠┼ ╞┴─╔╬╟ ═┼╙╙┴╟┼ ---Ç*CN0
╠ET'S CODE A COMMONLY NEEDED MESSAGE TO PRESS SOME KEY FOR ANY ACTION TO OCCUR, SUCH AS "PRESS Q TO QUIT", OR "PRESS ANY KEY TO CONTINUE", "WELCOME", OR WHATEVER. ╫E WANT TO DISPLAY THE MESSAGE ON THE TOP LINE OF THE SCREEN, IN THE LEFT HAND CORNER, UNCENTERED.
// PRG: PUSH Q //
Ç*FP5
*** ╓┴╥╔┴┬╠┼╙ ***
┴$ CONTAINS THE MESSAGE TO PRINT
╔$ KEYBOARD CHARACTER
╩ LUMINANCE LOOP INDEX
*** ╔╬╙╘╥╒├╘╔╧╬╙ ***
╘YPE THE CLEAR-THE-SCREEN CHARACTER IN THE QUOTES IN LINE 10, AND HOME THE CURSOR IN THE QUOTES IN LINE 60. ╥╒╬ THE PROGRAM, AND DO AS THE SCREEN SAYS: PUSH THE ╤-KEY TO STOP IT.
*** ─┼╘┴╔╠╙ ***
╘HE LOOP IN LINES 30 TO 70 REPRINTS THE MESSAGE CONTINUOUSLY IN THE FIRST POSITION OF THE SCREEN. ╘HE MESSAGE IS IN CURSOR COLOR WHITE (2), WITH BRIGHTNESSES (LUMINANCES) VARYING FROM 1 TO 7 (╔). ┴ND IT DOES SO OVER AND OVER UNTIL THE ╤-KEY IS PRESSED.
╘HAT'S JUST FOR STARTERS. ╙O FAR WE HAVE A BUILDING BLOCK. ╧FTEN WE NEED DIFFERENT MESSAGES FOR DIFFERENT CONDITIONS. ╫E MAY ALSO NEED TO PLACE MESSAGES IN DIFFERENT PLACES ON THE SCREEN, NOT JUST ON TOP, AS BEFORE.
Ç*CN1;--- ┬┼╘╘┼╥ ╞┴─╔╬╟ ═┼╙╙┴╟┼ ---Ç*CN0
╘HE PROGRAM IS LONGER, AS YOU CAN SEE. ┬UT IN THE LONG RUN, IT MAY PROVE MORE USEFUL AND MAY BE WORTH ATTACHING TO OTHER PROGRAMS THAT NEED A FLASHING MESSAGE. ╠ET'S CODE THIS: THE MESSAGE WILL FADE IN AND OUT, WILL BE CENTERED, AND WILL CAPABLE OF GOING ONTO ANY LINE OF THE SCREEN.
// PRG: FADING MSG //
Ç*FP9
*** ╓┴╥╔┴┬╠┼╙ ***
═$ MESSAGE TO PRINT, UP TO 39 LETTERS
├├ CURSOR COLOUR
╠╒ LUMINANCE
╥ SCREEN ROW (LINE) NUMBER COUNTED FROM ZERO
├ SCREEN COLUMN POSITION FOR CENTERING
─╠ AMOUNT OF DELAY FOR FLASHING
╔$ KEYBOARD ENTRY
*** ╔╬╙╘╥╒├╘╔╧╬╙ ***
╘HERE IS ONE GRAPHIC CHARACTER NEEDED TO BE TYPED IN: IN LINE 550 TYPE ╚╧═┼ IN QUOTES. ╥╒╬ THE PROGRAM AND PUSH ╤ TO QUIT, JUST AS THE SCREEN SAYS.
*** ─┼╘┴╔╠╙ ***
╘HE PROGRAM ORIGINALLY SETS UP ═$, ╥, ├├ AND ─╠. ╔T THEN CALLS A SUBROUTINE IN LINE 500 TO ACT ON THESE VALUES. ╘HE SUBROUTINE TAKES CARE OF PRINTING AND FADING THE MESSAGE UNTIL A KEY IS PUSHED. ╫HEN IT IS, WE TEST IF THE KEY WAS ╤, OR PERHAPS IN OTHER APPLICATIONS WE MIGHT BE INTERESTED IN OTHER KEYS. ╔N ANY CASE, IF THE KEY IS WRONG, WE CALL THE 500 SUBROUTINE AGAIN AND AGAIN. ╘HE REPETITION IS CODED IN LINE 140.
╠INE 500 CALCULATES THE TAB POSITION (HALF OF THE SPACES REMAINING AFTER YOU SUBTRACT LENGTH OF THE MESSAGE FROM 39), SETS THE LUMINANCE LEVEL (╠╒) TO 7, AND ╔$ TO NOTHING.
╘HEN WE LOOP UNTIL ANY KEY IS PUSHED. ╫E DO NOT CHECK WHAT KEY IT IS. ╙O LONG AS SOMETHING WAS PUSHED, WE RESET THE LUMINANCE TO A MIDDLE VALUE, WIPE THE MESSAGE OFF THE SCREEN, SEND THE CURSOR HOME AND RETURN TO LINE 130 WHICH CALLED US. ┴ SUBSEQUENT TEST IN THE MAIN PART OF THE PROGRAM CHECKS WHAT KEY WAS PUSHED. ╔T MIGHT HAVE BEEN SOME OTHER IMPORTANT KEY, IN WHICH CASE THE PROGRAM WOULD CONTINUE PAST LINE 140.
╠INES 510-540 PRINT THE MESSAGE AT ROW ╥ AND TAB POSITION ├ (BOTH ARE COUNTED FROM ZERO). ╘HIS IS DONE USING A CONVENIENT COMMAND ├╚┴╥. ╔N LINE 530 WE DELAY. ╔N LINE 540 WE INCREASE THE LUMINANCE TO 7, OR IF IT HAS GONE PAST 7 WE WRAP IT UP BACK TO ZERO, AND WE LOOP.
╫HEN THE KEY IS PRESSED, WE SET THE LUMINANCE TO MEDIUM, WE WIPE OFF THE MESSAGE USING THE ┼╙├-KEY FUNCTIONS TO ERASE PARTS OF A LINE. ╘HAT'S WHAT THE ├╚╥$(27) FOLLOWED BY "╨" DOES. ╫E PRINT CURSOR-HOME TO BE NEAT AND RETURN TO THE MAIN CODE.
*** ╨╥╧╩┼├╘ ***
╘HIS ROUTINE COULD STILL BE IMPROVED IN THE DIRECTION OF NON-INTERFERENCE WITH THE MAIN CODE: WE COULD TRY TO REMEMBER THE EXISTING CURSOR COLOR AND ITS LUMINANCE, AND PLUG THOSE VALUES BACK IN AFTER ╤ IS PUSHED. ┘OU CAN TRY DOING IT, IF YOU WISH. ╠OOK IN THE MANUAL FOR A COMMAND ╥├╧╠ - IT TELLS YOU WHAT COLOR IS BEING USED FOR THE CURSOR OR THE SCREEN.
╞URTHER, YOU CAN TRY USING THE BUILT IN FLASHER. ╩UST AS YOU CODE QUOTE / CTRL-RVS / TEXT / CTRL-OFFRVS TO PRINT THINGS IN REVERSE, YOU CAN FLASH THEM, BY SUBSTITUTING LOGO-FLASH-ON OR LOGO-FLASH-OFF. ┬UT THE EFFECT IS NOT THE SAME.
╘HERE IS A USEFUL FUNCTION BUILT IN THE MACHINE: ╥╠╒═(X). ╔T TELLS WHAT LUMINANCE IS CURRENTLY BEING USED WITH THE "COLOR SOURCE" X. ╔T IS DESCRIBED IN THE MANUAL. ╘HE ABOVE ROUTINE CAN BE MADE MUCH SIMPLER IF YOU USED THE FUNCTION. "├OLOR SOURCE" MEANS WHICH OF THE FOUR POSSIBLE COLOR SETTINGS WE'RE DEALING WITH: (0) SCREEN, (1) CURSOR, (2) MULTICOLOR 1, (3) MULTICOLOR 2, (4) SCREEN EDGE. ╧F CONCERN TO YOU, AT THIS MOMENT, ARE NUMBERS ZERO, ONE AND FOUR.
*** ├╚┴╥ ├╧══┴╬─ ***
╘HE ├╚┴╥ COMMAND IS A NEWCOMER IN ├OMMODORE COMPUTERS. ╔T IS CONVENIENT AND SIMPLE TO USE. ╫HENEVER YOU NEED TO QUICKLY PLACE SOMETHING AT ROW ╥ OR ├, THAT'S THE COMMAND TO USE. ╫HEN IT HAS FINISHED PRINTING, IT BEHAVES AS IF THERE WERE A SEMICOLON AT THE END IN AN EQUIVALENT ╨╥╔╬╘ STATEMENT. ╘HIS IS VERY HANDY, BUT CAN CAUSE CONFUSION. ─ON'T FORGET, THERE IS NO SUCH THING AS AN AUTOMATIC CARRIAGE RETURN WHEN THE SEMICOLON IS ABSENT.
├╚┴╥ COMMAND CAN BE USED ON A HIGH RESOLUTION SCREEN. ╔T CAN PRINT JUST ABOUT EVERYTHING THERE EXCEPT THE COLORS. ╔T CAN ONLY HANDLE CHARACTER STRINGS. (┘OU CAN THINK OF ├╚┴╥ AS A SUBSET OF ╨╥╔╬╘, ╨╥╔╬╘ CAN DO MORE). ╙O, IF YOU NEED TO PRINT NUMBERS, CONVERT THEM TO STRINGS. ╔F ┴=5, THEN YOU ╨╥╔╬╘ ┴, BUT YOU ├╚┴╥ -- ╙╘╥$(┴). ╫E WILL LOOK AT DETAILS LATER, THIS IS JUST A HINT TO GET YOU STARTED.
╞INALLY, ├╚┴╥ CAN BE USED TO POSITION THE CURSOR ANYPLACE ON THE SCREEN, BUT PRINT NOTHING. ╔N THIS CASE, THE SYNTAX IS ├╚┴╥ X,ROW,COL,"". ╙TRANGELY ENOUGH, THE NULL STRING, THE DOUBLE QUOTE IS NEEDED. ╘HINGS WON'T WORK WITHOUT IT.
*** ┼╙├ ***
├╚╥$(27) IS AN ┴╙├╔╔ CODE FOR ┼╙├ KEY. ╔F YOU TYPED ┼╙├ KEY INSIDE THE QUOTES, NOTHING WOULD SHOW, SO WE COULDN'T DO THE JOB. ╙O WE LOOK IN THE APPENDIX FOR ┴╙├╔╔ CODE FOR ┼╙├, FIND IT IS 27, AND CODE ╨╥╔╬╘ ├╚╥$(27) TO DO THE SAME THING. ╞OLLOW IT WITH A "╨" TO WIPE THE LINE, AND THAT'S ALL THERE IS TO IT.
*** ╙╔═╨╠┼ ├╧─┼ ├╧╬╓┼╥╙╔╧╬ ***
┼╙├ CAN, OF COURSE, BE USED IN DIRECT MODE. ┘OU CAN TYPE KEYS: ┼╙├, THEN ╨ TO DO THE SAME THING. ╠OOK IN THE INDEX OF THE MANUAL FOR OTHER THINGS ┼╙├ CAN DO. ╔T'S CAPABLE OF SCREEN DAZZLERS.
├AN YOU THINK OF HOW YOU COULD CODE THE FOLLOWING CONTROL KEYS IF YOU COULD NOT WRITE IN A PROGRAM "HOME" OR "RVS" OR "CLEAR-SCREEN"? ╚INT: USE ├╚╥$(A NUMBER YOU LOOKED UP IN THE ┴╙├╔╔ TABLES). ╘RY IT, IT'S A GOOD EXERCISE.
╫HILE WE'RE AT IT, NO TABLES ARE THE BEST TABLES. ╫ANT TO KNOW THE ┴╙├╔╔ CODE FOR CURSOR-HOME? ├AN'T FIND THE MAGIC TABLES? ┘OU CAN ASK THE COMPUTER:
╨╥╔╬╘ ┴╙├("NOW HIT HOME");
IN THE QUOTES DON'T TYPE THE NOW-HIT-HOME SUGGESTION. ╘YPE THE ╚╧═┼ KEY, (UNSHIFTED-├╠┼┴╥/╚╧═┼), INSTEAD. ╘HE COMPUTER WILL TELL YOU ITS ┴╙├╔╔ VALUE X, SO LATER YOU CAN CODE ├╚╥$(X).
╚OW ABOUT ├╠┼┴╥ (├╠┼┴╥/╚╧═┼-SHIFTED)? ╚OW ABOUT ╥╓╙ (├╘╥╠ 9), JUST A PLAIN LETTER ┴, WHAT ABOUT SHIFTED ┴? ╘RY THEM, THE COMPUTER PATIENTLY ANSWERS YOUR QUERIES, SO DON'T EVER FORGET IT'S THERE TO HELP YOU IF YOU CAN'T FIND YOUR TABLES.
╘HE POINT OF THE CODE CONVERSION STORY IS THAT FUNCTIONS SUCH AS ┴╙├ OR ├╚╥$ OR ╓┴╠, ARE NOT LIMITED TO STUFFY PROGRAMS. ╘HEY CAN BE USED IN ASKING THE COMPTER THE QUESTIONS YOU NEED ANSWERED. ╘HAT'S WHY THEY ARE WORTH LEARNING ABOUT.